package cn.edu.nwsuaf.examcenter.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Major entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "major", catalog = "exam")
public class Major implements java.io.Serializable {

	// Fields

	private String majorNo;
	private College college;
	private String majorName;
	private Set<Grade> grades = new HashSet<Grade>(0);

	// Constructors

	/** default constructor */
	public Major() {
	}

	/** minimal constructor */
	public Major(String majorNo, College college, String majorName) {
		this.majorNo = majorNo;
		this.college = college;
		this.majorName = majorName;
	}

	/** full constructor */
	public Major(String majorNo, College college, String majorName,
			Set<Grade> grades) {
		this.majorNo = majorNo;
		this.college = college;
		this.majorName = majorName;
		this.grades = grades;
	}

	// Property accessors
	@Id
	@Column(name = "major_no", unique = true, nullable = false, length = 50)
	public String getMajorNo() {
		return this.majorNo;
	}

	public void setMajorNo(String majorNo) {
		this.majorNo = majorNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "college_no", nullable = false)
	public College getCollege() {
		return this.college;
	}

	public void setCollege(College college) {
		this.college = college;
	}

	@Column(name = "major_name", nullable = false, length = 50)
	public String getMajorName() {
		return this.majorName;
	}

	public void setMajorName(String majorName) {
		this.majorName = majorName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "major")
	public Set<Grade> getGrades() {
		return this.grades;
	}

	public void setGrades(Set<Grade> grades) {
		this.grades = grades;
	}

}